/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO;

import DAO.Iter.AdminDAO;
import TableModel.Admin;
import java.io.Serializable;
import java.util.List;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;


/**
 *
 * @author vt
 */
class AdminDaoImpl extends HibernateDaoSupport implements AdminDAO{

    @Override
    public Admin findAdmin(String id) {
       List list = this.getHibernateTemplate().find("from Admin admin where admin.maad = ?", id);
		if(list.isEmpty()){
			return null;
		}
		return (Admin) list.get(0);
    }

    @Override
    public Admin findAdmin(String userName, String paawrod) {
         List list = this.getHibernateTemplate().find("from Admin admin where admin.name = ? and admin.password=?", userName,paawrod);
		if(list.isEmpty()){
			return null;
		}
		return (Admin) list.get(0);
    }

    @Override
    public List<Admin> findAllAdmin() {
         return  getHibernateTemplate().find("from Admin");
    }

    @Override
    public void addAdmin(Admin a) {
       Serializable save = getHibernateTemplate().save(a);
       
    }

    @Override
    public void deleteAdmin(Admin a) {
         getHibernateTemplate().delete(a);
    }

    @Override
    public void editAdmin(Admin a) {
       getHibernateTemplate().update(a);
    }
    
}
